package com.shujia.scala

object Demo18Extend {
  def main(args: Array[String]): Unit = {

    val student = new Student1("张三", 23)

    println(student)

  }
}

class Person(_name: String) {
  val name: String = _name

  override def toString = s"Person($name)"
}

//继承父类。把父类的方法和属性都继承过来
class Student1(_name: String, _age: Int) extends Person(_name) {
  var age: Int = _age

  override def toString = s"Student1($name,$age)"
}

